// If you are in "stata" or "code" folder, type:
use ../data/data_final.dta, clear


// Keep only electoral years (1994, 1998, 2002, 2006, 2010, 2014) 
drop if elecyear != 1

// Set time series and cross section
xtset uf_cod year

// Generate lags

**  Incumbent vote in the previous election
gen l4vote = l4.elecvote
**  Previous incumbent vote in the previous election
gen l4votesh = l4.vote_share


// Generate interactions

** State unemployment and industry+services 
gen un_ind1 = ind_ser*unempch_uf
** Benchmark unemployment and industry+services 
gen un_ind2 = ind_ser*unempch_rel
** State unemployment and taxes
gen un_tax1 = tax*unempch_uf
** Benchmark unemployment and taxes
gen un_tax2 = tax*unempch_rel

// Keep only included observations
drop if included != 1

// SEED
set seed 1234

** USING CLARIFY **

// INTERACTIVE MODDEL 2: m2_interaction_labor 
sum vote_share l4vote incumbent unempch_rel tax un_ind2 ind_ser if included == 1
estsimp reg vote_share l4vote incumbent unempch_rel tax un_ind2 ind_ser if included == 1, vce(cluster uf)


* Since sum unempch_rel if included==1

* One standard deviation above (worsening unemployment) 

di  .2526193  +  1.723132

di  .2526193  -  1.723132

** relative unemployment at 3.6988833 (2 SD)
setx l4vote 49.7 incumbent 1 unempch_rel 3.6988833 tax 51.5 ind_ser 80 un_ind2 295.91066
simqi, ev level(95)

** relative unemployment at 1.9757513  (1 SD)
setx l4vote 49.7 incumbent 1 unempch_rel 1.9757513 tax 51.5 ind_ser 80 un_ind2 158.0601
simqi, ev level(95)

** relative unemployment at mean unempch_rel 
setx l4vote 49.7 incumbent 1 unempch_rel .2526193 tax 51.5 ind_ser 80 un_ind2 20.209544
simqi, ev level(95)

** relative unemployment at -1.5 (1 SD)
setx l4vote 49.7 incumbent 1 unempch_rel -1.4705127 tax 51.5 ind_ser 80 un_ind2 -120
simqi, ev level(95)

** relative unemployment at  -3.1936447 (2 SD)
setx l4vote 49.7 incumbent 1 unempch_rel -3.1936447 tax 51.5 ind_ser 80 un_ind2 -255.49158
simqi, ev level(95)



drop b1 b2 b3 b4 b5 b6 b7 b8
